<script type="text/javascript">
var $datatable;
var $dialog_form_edit;
var $dialog_form_add;
var $dialog_confrim_delete;
var _DATATABLE_TR;
var oTable;
var $_PRODUCT_SELECTED;
var FLAG_WARP_RIGHT_CLICK = true;
var FLAG_WARP_LEFT_CLICK = true;
var FLAG_TABLE_EDIT_CLICK = true;
    
$(document).ready(function() {
    $datatable = $('#datatable_bill');
    $dialog_form_edit = $('#dialog_form_edit');
    $dialog_form_add = $('#dialog_form_add');
    $dialog_confrim_delete = $('#dialog_confrim_delete');
    
    oTable = $datatable.dataTable({
        "bJQueryUI": true,
        //"sPaginationType": "full_numbers",
        "bInfo": false,
        //"bProcessing": true,
        //"bServerSide": true,
        //"iDisplayStart": 0,
        //"iDisplayLength": 100,
        "bPaginate": false,
        "bFilter" : false,
        "bLengthChange": false,
        "bInfo": false,
        //"sScrollY": "300px",
        //"bScrollCollapse": true,
        //"bFilter": false,
        //"sAjaxSource": $datatable.attr('active_url'),
        "fnDrawCallback": function( oSettings ) {
            //$("#datatable_nb_wrapper").find(".fg-toolbar").removeClass("ui-widget-header");
            datatable_selected();
            _DATATABLE_TR = null;
        },
        "aoColumns": [
          { "sClass": "ci_checkbox","bSortable": false},
          { "sClass": "stt","bSortable": false},
          { "sClass": "itext ci_product edittable","bSortable": false },
          { "sClass": "ci_category edittable","bSortable": false },
          { "sClass": "itext ci_boschcode edittable","bSortable": false },
          { "sClass": "ci_department","bSortable": false },
          { "sClass": "itext ci_branding edittable","bSortable": false },
          { "sClass": "itext ci_branding edittable","bSortable": false },
        ],
        "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
            $(nRow).attr("stt",iDisplayIndex);
            $(nRow).attr("modify",'edit');
            $('td:eq(0)', nRow).html( iDisplayIndex+1 );
            return nRow;
        }        
    });
    dialogFormAddNew();
    dialogConfrimDelete();
    dialogFormEdit();
    dialogError();
    product_filter();
    import_product();
    input_number();
    input_price();
} );

function datatable_selected(){
    $datatable.find('tbody tr[modify=edit]').unbind("click");
    $datatable.find('tbody tr[modify=edit]').bind('click', function( e ) {
        if ( $(this).hasClass('row_selected') ) {
            $(this).removeClass('row_selected');
            _DATATABLE_TR = null;
        }else {
            oTable.$('tr.row_selected').removeClass('row_selected');
            $(this).addClass('row_selected');
            _DATATABLE_TR = $(this).attr('stt');
        }
    });

    $datatable.find('tbody tr[modify=edit]').unbind("dblclick");
    $datatable.find('tbody tr[modify=edit]').bind("dblclick", function(){
        if ( !$(this).hasClass('row_selected') ) {
            $(this).addClass('row_selected');
        }
        _DATATABLE_TR = $(this).attr('stt');
        //even_edit_dbclick( _DATATABLE_TR );
        var $TD = $(this).find('td:eq(5)');
        var product_id = $TD.find('input').attr('product_id');
        var import_total = $TD.find('input').val();
        
        var $TD_PRICE = $(this).find('td:eq(6)');
        var import_price = $TD_PRICE.find('input').val();
        
        var $TD_NOTE = $(this).find('td:eq(7)');
        var note = $TD_NOTE.find('input').val();
        
        even_edit_dbclick( product_id,import_total,import_price,note );

    });

}

function even_edit_dbclick(pro_id,import_total,import_price,note){
    if(FLAG_TABLE_EDIT_CLICK == true){
        FLAG_TABLE_EDIT_CLICK = false;
        $('#warpp-right-content').fadeOut(200,function(){
            $('#warpp-right-loading').fadeIn(400,function(){
                var url = $dialog_form_edit.attr('active_url');
                $.post(url, { id: pro_id, import_total: import_total,import_price: import_price,note: note },function(data) {
                    $dialog_form_edit.html( data );
                    input_number();
                    input_price();
                    $dialog_form_edit.dialog( "open" );
                    $('#warpp-right-loading').delay(300).fadeOut(100,function(){
                        $('#warpp-right-content').fadeIn(200);
                        FLAG_TABLE_EDIT_CLICK = true;
                    });
                });
            });
        });
    }
    
    /*var url = $dialog_form_edit.attr('active_url');
        
    $.post(url, { id: pro_id, import_total: import_total,import_price: import_price,note: note },function(data) {
        $dialog_form_edit.html( data );
        input_number();
        input_price();
        $dialog_form_edit.dialog( "open" );
    });*/
}

function dialogFormAddNew(){
    
    $dialog_form_add.dialog({
        autoOpen: false,
        //height: 300,
        width: 420,
        modal: true,
        resizable: true,
        buttons: {
            "<?php print lang('btn_save') ?>": function() {
                var flag = true;
                var msg = '';
                var total = $dialog_form_add.find('input[name=total]').val();
                var product_id = $dialog_form_add.find('input[name=product_id]').val();
                var import_total = $dialog_form_add.find('input[name=import_total]').val();
                var import_price = $dialog_form_add.find('input[name=import_price]').val();
                
                var code = $dialog_form_add.find('input[name=code]').val();
                var name = $dialog_form_add.find('input[name=name]').val();
                var value = $dialog_form_add.find('input[name=value]').val();
                var category = $dialog_form_add.find('input[name=category]').val();
                var note = $dialog_form_add.find('input[name=note]').val();
                
                if(import_total == '' || parseFloat(import_total) <= 0 ){
                    flag = false;
                    msg += '<p>Total ko hop le</p>';
                    $dialog_form_add.find('#error_import_total').show();
                    $dialog_form_add.find('input[name=import_total]').addClass("i-error");
                }else{
                    if (isNaN( import_total )) {
                        // It isn't a number
                        flag = false;
                        msg += '<p>Total ko hop le</p>';
                        $dialog_form_add.find('#error_import_total').show();
                        $dialog_form_add.find('input[name=import_total]').addClass("i-error");
                    } else {
                        // It is a number
                        $dialog_form_add.find('#error_import_total').hide();
                        $dialog_form_add.find('input[name=import_total]').removeClass("i-error");
                    }
                    //$dialog_form_add.find('input[name=import_total]').removeClass("i-error");
                }
                if(import_price == '' || parseFloat(import_price) <= 0){
                    flag = false;
                    msg += '<p>Don gia ko hop le</p>';
                    $dialog_form_add.find('#error_import_price').show();
                    $dialog_form_add.find('input[name=import_price]').addClass("i-error");
                }else{
                    if (isNaN( import_price )) {
                        // It isn't a number
                        flag = false;
                        msg += '<p>Don gia ko hop le</p>';
                        $dialog_form_add.find('#error_import_price').show();
                        $dialog_form_add.find('input[name=import_price]').addClass("i-error");
                    } else {
                        $dialog_form_add.find('#error_import_price').hide();
                        // It is a number
                        $dialog_form_add.find('input[name=import_price]').removeClass("i-error");
                    }
                    //$dialog_form_add.find('input[name=import_price]').removeClass("i-error");
                }
                
                if( flag == true){
                    $_PRODUCT_SELECTED.removeClass('pro-add');
                    $_PRODUCT_SELECTED.addClass('pro-dis');
                    $_PRODUCT_SELECTED.attr('act','disable');
                    $('.list-item-icon[value_id='+product_id+']').removeClass('icon-pro-def');
                    $('.list-item-icon[value_id='+product_id+']').addClass('icon-pro-add');
                    add_new_row(product_id,code,name,value,import_total,category,note,import_price);
                    $(this).dialog( "close" );
                }
            },
            "<?php print lang('btn_cancel') ?>": function() {
                $( this ).dialog( "close" );
            }
        },
        close: function() {
            $dialog_form_add.html('');
        }
    });
        
}

function dialogFormEdit(){
    
    $dialog_form_edit.dialog({
        autoOpen: false,
        //height: 300,
        width: 420,
        modal: true,
        resizable: true,
        buttons: {
            "<?php print lang('btn_delete'); ?>": function() {
                even_delete();
                $( this ).dialog( "close" );
            },
            "<?php print lang('btn_save') ?>": function() {
                var flag = true;
                var msg = '';
                var total = $dialog_form_edit.find('input[name=total]').val();
                var product_id = $dialog_form_edit.find('input[name=product_id]').val();
                var import_total = $dialog_form_edit.find('input[name=import_total]').val();
                var import_price = $dialog_form_edit.find('input[name=import_price]').val();
                
                var code = $dialog_form_edit.find('input[name=code]').val();
                var name = $dialog_form_edit.find('input[name=name]').val();
                var value = $dialog_form_edit.find('input[name=value]').val();
                var category = $dialog_form_edit.find('input[name=category]').val();
                var note = $dialog_form_edit.find('input[name=note]').val();
                
                if(import_total == '' || parseFloat(import_total) <= 0 ){
                    flag = false;
                    msg += '<p>Total ko hop le</p>';
                    $dialog_form_edit.find('#error_import_total').show();
                    $dialog_form_edit.find('input[name=import_total]').addClass("i-error");
                }else{
                    if (isNaN( import_total )) {
                        // It isn't a number
                        flag = false;
                        msg += '<p>Total ko hop le</p>';
                        $dialog_form_edit.find('#error_import_total').show();
                        $dialog_form_edit.find('input[name=import_total]').addClass("i-error");
                    } else {
                        // It is a number
                        $dialog_form_edit.find('#error_import_total').hide();
                        $dialog_form_edit.find('input[name=import_total]').removeClass("i-error");
                    }
                    //$dialog_form_add.find('input[name=import_total]').removeClass("i-error");
                }
                if(import_price == '' || parseFloat(import_price) <= 0){
                    flag = false;
                    msg += '<p>Don gia ko hop le</p>';
                    $dialog_form_edit.find('#error_import_price').show();
                    $dialog_form_edit.find('input[name=import_price]').addClass("i-error");
                }else{
                    if (isNaN( import_price )) {
                        // It isn't a number
                        flag = false;
                        msg += '<p>Don gia ko hop le</p>';
                        $dialog_form_edit.find('#error_import_price').show();
                        $dialog_form_edit.find('input[name=import_price]').addClass("i-error");
                    } else {
                        $dialog_form_edit.find('#error_import_price').hide();
                        // It is a number
                        $dialog_form_edit.find('input[name=import_price]').removeClass("i-error");
                    }
                    //$dialog_form_add.find('input[name=import_price]').removeClass("i-error");
                }
                
                if( flag == true){
                    var html_import_total = import_total+'<input name="product_total['+ product_id +']" product_id="'+ product_id +'" value="'+ import_total +'" type="hidden">';
                    var html_import_price = import_price+'<input name="product_price['+ product_id +']" product_id="'+ product_id +'" value="'+ import_price +'" type="hidden">';
                    var html_import_note = note+'<input name="product_note['+ product_id +']" product_id="'+ product_id +'" value="'+ note +'" type="hidden">';
                    var $tr = oTable.$('tr[stt="'+ _DATATABLE_TR +'"]');
                    $tr.find('td:eq(1)').html(code);
                    $tr.find('td:eq(2)').html(name);
                    $tr.find('td:eq(3)').html(value);
                    $tr.find('td:eq(4)').html(category);
                    $tr.find('td:eq(5)').html(html_import_total);
                    $tr.find('td:eq(6)').html(html_import_price);
                    $tr.find('td:eq(7)').html(html_import_note);
                    $(this).dialog( "close" );
                }
            },
            "<?php print lang('btn_cancel') ?>": function() {
                $( this ).dialog( "close" );
            }
            
        },
        close: function() {
            $dialog_form_edit.html('');
        }
    });
        
}

function dialogConfrimDelete(){
    
    $dialog_confrim_delete.dialog({
        autoOpen: false,
        //height: 300,
        width: 320,
        modal: true,
        resizable: true,
        buttons: {
            "Delete": function() {
                delete_new_row();
                
                $( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        },
        close: function() {
            //allFields.val( "" ).removeClass( "ui-state-error" );
        }
    });
        
}

function even_add(pro_id){
    
    if(FLAG_WARP_LEFT_CLICK == true){
        FLAG_WARP_LEFT_CLICK = false;
        
        $('#product-list').fadeOut(200,function(){
            $('#warpp-left-loading').fadeIn(200,function(){
                var url = $dialog_form_add.attr('active_url');
                $.post(url, { id: pro_id },function(data) {
                    $dialog_form_add.html( data );
                    input_number();
                    input_price();
                    $dialog_form_add.dialog( "open" );
                    $('#warpp-left-loading').delay(100).fadeOut(200,function(){
                        $('#product-list').fadeIn(200);
                        FLAG_WARP_LEFT_CLICK = true;
                    });
                    
                });
                
            });
        });
    }
    
    /*var url = $dialog_form_add.attr('active_url');
    $.post(url, { id: pro_id },function(data) {
        $dialog_form_add.html( data );
        input_number();
        input_price();
        $dialog_form_add.dialog( "open" );
    });*/
}

function even_edit(){
    if(_DATATABLE_TR != null){
        var $TR = $datatable.find('tbody tr:eq('+ _DATATABLE_TR +')');
        var $TD = $TR.find('td:eq(5)');
        var product_id = $TD.find('input').attr('product_id');
        var import_total = $TD.find('input').val();
        
        var $TD_PRICE = $TR.find('td:eq(6)');
        var import_price = $TD_PRICE.find('input').val();
        
        var $TD_NOTE = $TR.find('td:eq(6)');
        var note = $TD_NOTE.find('input').val();
        even_edit_dbclick( product_id,import_total,import_price,note );
    }else{
        $dialog_error.html( '<?php print lang('error_noselected'); ?>' );
        $dialog_error.dialog( "open" );
    }
}

function even_delete(){
    if(_DATATABLE_TR != null){
        $dialog_confrim_delete.dialog( "open" );
    }else{
        $dialog_error.html( '<?php print lang('error_noselected'); ?>' );
        $dialog_error.dialog( "open" );
    }
}

/*
    product Filter
*/
function product_filter(){
    //Category Filter
    $('#catg-filter').change(function(){
        var catg = $(this).val();
        $('#product-list .list-item').css('display', 'block');
        if (catg != '0'){
            $('#product-list .list-item[data-catg!="'+ catg +'"]').css('display', 'none');
        }
    });
    
    // Do the actual search/filtering
    $('input#pro-filter').keyup(function(e){
        e.preventDefault();
        var term = $(this).val().toLowerCase();
        $('#product-list .list-item').css('display', 'block');
        $('#product-list .list-item').each(function(intIndex){
            var field = $(this).children('p').text().toLowerCase();
            if (field.indexOf(term) == -1){
                $(this).css('display', 'none');
            }
        });
    });
}

function add_new_row(pro_id,code,name,value,import_total,category,note,import_price){    
    oTable.fnAddData( [
        '',
        code,
        name,
        value,
        category,
        import_total+'<input name="product_total['+ pro_id +']" product_id="'+ pro_id +'" value="'+ import_total +'" type="hidden">',
        import_price+'<input name="product_price['+ pro_id +']" product_id="'+ pro_id +'" value="'+ import_price +'" type="hidden">',
        note+'<input name="product_note['+ pro_id +']" product_id="'+ pro_id +'" value="'+ note +'" type="hidden">'
    ] );
}

function delete_new_row(){
    var aTrs = oTable.fnGetNodes();

    if(_DATATABLE_TR != null){
        //
        var $TR = $datatable.find('tbody tr:eq('+ _DATATABLE_TR +')');
        var $TD = $TR.find('td:eq(5)');
        var product_id = $TD.find('input').attr('product_id');
        $('.add-product[value_id='+product_id+']').removeClass('pro-dis');
        $('.add-product[value_id='+product_id+']').addClass('pro-add');
        $('.add-product[value_id='+product_id+']').attr('act','add');
        $('.list-item-icon[value_id='+product_id+']').removeClass('icon-pro-add');
        $('.list-item-icon[value_id='+product_id+']').addClass('icon-pro-def');
        
        oTable.fnDeleteRow(aTrs[_DATATABLE_TR]);
        _DATATABLE_TR = null;
    }else{
        $dialog_error.html( '<?php print lang('error_noselected'); ?>' );
        $dialog_error.dialog( "open" );
    }
}

function import_product(){
    //$datatable.find('tbody tr[modify=edit]').unbind("click");
    $('.add-product').bind('click', function() {
        var act = $(this).attr('act');
        var pro_id = $(this).attr('value_id');
        if( act == 'add' ){
            $_PRODUCT_SELECTED = $(this);
            even_add(pro_id);
            /*
            $(this).removeClass('pro-add');
            $(this).addClass('pro-dis');
            $(this).attr('act','disable');
            
            $('.list-item-icon[value_id='+pro_id+']').removeClass('icon-pro-def');
            $('.list-item-icon[value_id='+pro_id+']').addClass('icon-pro-add');
            //alert( $(this).attr('value_id') );
            add_new_row(pro_id);
            */
        }
        
    });
}

function import_product_save(){
    /*
    var bill_code = $('input[name=bill_code]').val();
    var bill_total = $('input[name=bill_total]').val();
    var bill_vat = $('input[name=bill_vat]').val();
    var bill_vatprice = $('input[name=bill_vatprice]').val();
    var bill_totalvat = $('input[name=bill_totalvat]').val();
    var flag = true;
    
    if(bill_code == ''){
        flag = false;
        $('input[name=bill_code]').addClass("i-error");
    }else{
        $('input[name=bill_code]').removeClass("i-error");
    }
        
    if(bill_total == '' || bill_total < 0){
        flag = false;
        $('input[name=bill_total]').addClass("i-error");
    }else{
        if (isNaN( bill_total )) {
            // It isn't a number
            flag = false;
            $('input[name=bill_total]').addClass("i-error");
        } else {
            // It is a number
            $('input[name=bill_total]').removeClass("i-error");
        }
    }
    
    if(bill_vat == '' || bill_vat < 0){
        flag = false;
        $('input[name=bill_vat]').addClass("i-error");
    }else{
        if (isNaN( bill_vat )) {
            // It isn't a number
            flag = false;
            $('input[name=bill_vat]').addClass("i-error");
        } else {
            // It is a number
            $('input[name=bill_vat]').removeClass("i-error");
        }
    }
    
    if(bill_vatprice == '' || bill_vatprice < 0){
        flag = false;
        $('input[name=bill_vatprice]').addClass("i-error");
    }else{
        if (isNaN( bill_vatprice )) {
            // It isn't a number
            flag = false;
            $('input[name=bill_vatprice]').addClass("i-error");
        } else {
            // It is a number
            $('input[name=bill_vatprice]').removeClass("i-error");
        }
    }
    
    if(bill_totalvat == '' || bill_totalvat < 0){
        flag = false;
        $('input[name=bill_totalvat]').addClass("i-error");
    }else{
        if (isNaN( bill_totalvat )) {
            // It isn't a number
            flag = false;
            $('input[name=bill_totalvat]').addClass("i-error");
        } else {
            // It is a number
            $('input[name=bill_totalvat]').removeClass("i-error");
        }
    }
    
    var count = 0;
    $datatable.find('tbody tr').each(function(){
        var $row = $(this);
        var cols = $row.find("td:eq(5)").find('input').val();
        if( cols != undefined){
            count++;
        }
    });
    
    if(count <= 0){
        flag = false;
    }
    
    if(flag == true){
        $('#frm-import-product').submit();
    }else{
        alert('co loi xay ra');
    }
    */

    if(FLAG_WARP_RIGHT_CLICK == true){
        FLAG_WARP_RIGHT_CLICK = false;
        
        $('#warpp-right-content').fadeOut(400,function(){
            $('#warpp-right-loading').fadeIn(400,function(){
                
                $("#frm-import-product").ajaxSubmit({
                    dataType:  'json',
                    /*beforeSubmit: function(formData, jqForm, options) {
                        return validate_frm();
                    },*/
                    success: function(data) {
                        if(data.flag == true){
                            window.location.href = data.url;
                        }else{
                            $("input.i-error").removeClass("i-error");
                            $("select.i-error").removeClass("i-error");
                            $("div.error").hide();
                            $.each(data.error, function(key, value) {
                                $("input[name="+value.name+"]").addClass("i-error");
                                $("select[name="+value.name+"]").addClass("i-error");
                                $("#error_"+value.name).html(value.message);
                                $("#error_"+value.name).show();
                            });
                            
                            $('#warpp-right-loading').delay(200).fadeOut(400,function(){
                                $('#warpp-right-content').fadeIn(500);
                                FLAG_WARP_RIGHT_CLICK = true;
                            });
                            
                            
                            
                        }
                    }
                });
                
            });
        });
        
        
    }
}
</script>

<!--
<div class="page-title 1ui-widget-header">
    <div class="title">Phieu Nhap KHo</div>
</div>
-->
<div class="warpp">
    
    <div class="warpp-left">
        <div class="panel-listsearch">
            <select id="catg-filter" style="display: inline-block; max-width: 50%;">
                <option value="0"><?php print lang('vt_chonphanloai'); ?></option>
                <?php if( count($categories) > 0): ?>
                <?php foreach($categories As $category): ?>
                <option value="<?php print $category->id; ?>"><?php print $category->name; ?></option>
                <?php endforeach; ?>
                <?php endif; ?>
            </select>
            <div style="" id="search-form">
                <input id="pro-filter" type="text" placeholder="search..." value="" class="list-search">
            </div>
        </div>
        <div id="warpp-left-loading" style="display: none;">
            <img class="icon_loading_1" src="<?php print base_url('template/ess/images/loading/loading_3.gif') ?>" alt="loading...">
        </div>
        <div id="product-list" class="scrollable-listsearch">
            <?php if( count($products) > 0 ): ?>
            <?php foreach( $products As $product ): ?>
            <div data-catg="<?php print $product->catg_id; ?>" data-id="<?php print $product->id; ?>" data-value="<?php print $product->unit_id; ?>" class="list-item with-icon">
                <div class="list-item-icon icon-pro-def" value_id="<?php print $product->id; ?>"></div>
                <p>
                    <b><span filter="name"><?php print $product->name; ?></span></b><br>
                    <i><span filter="code"><?php print $product->code; ?></span></i><br>
                    <span filter="total"><?php print decimal_format($product->total); ?></span>
                </p>
                <div class="add-product pro-add" act="add" value_id="<?php print $product->id; ?>"></div>
            </div>
            <?php endforeach; ?>
            <?php endif; ?>    
        </div>
    </div>
    <div class="warpp-right">
        <div id="warpp-right-loading" style="display: none;">
            <img class="icon_loading_1" src="<?php print base_url('template/ess/images/loading/loading_3.gif') ?>" alt="loading...">
        </div>
        <div id="warpp-right-content">
            <?php
                $attributes = array('class' => 'frm', 'id' => 'frm-import-product');
                print form_open('nk/import_product', $attributes);
            ?>
                <div>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                <table>
                                    <tbody>
                                        <tr>
                                            <td><label><?php print lang('vt_nguoinhap'); ?>:</label></td>
                                            <td><?php print $this->jimauth->username(); ?>
                                                <input type="hidden" name="created_by" value="<?php print $this->jimauth->user_id(); ?>">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><div id="error_created_by" class="error"></div></td>
                                        </tr>
                                        <tr>
                                            <td><label><?php print lang('vt_maphieunhap'); ?>:</label></td>
                                            <td><input name="bill_code" value="" class="itext ivalidate ui-widget-content ui-corner-all"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><div id="error_bill_code" class="error"></div></td>
                                        </tr>
                                        <tr>
                                            <td><label><?php print lang('vt_nhacungcap'); ?>:</label></td>
                                            <td>
                                                <select name="supplier_id" class="itext ivalidate ui-widget-content ui-corner-all">
                                                    <?php if( count($suppliers) > 0 ): ?>
                                                    <?php foreach($suppliers As $supp):?>
                                                        <option value="<?php print $supp->id; ?>"><?php print $supp->supplier_name; ?></option>
                                                    <?php endforeach; ?>
                                                    <?php endif; ?>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><div id="error_supplier_id" class="error"></div></td>
                                        </tr>
                                        <tr>
                                            <td><label><?php print lang('vt_total-vat'); ?>:</label></td>
                                            <td><input type="text" name="bill_total" id="bill_total" value="0" class="input-price itext ivalidate ui-widget-content ui-corner-all"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><div id="error_bill_total" class="error"></div></td>
                                        </tr>
                                        <tr>
                                            <td><label><?php print lang('vt_vat%'); ?>:</label></td>
                                            <td><input name="bill_vat" id="bill_vat" value="0" class="input-number itext ivalidate ui-widget-content ui-corner-all"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><div id="error_bill_vat" class="error"></div></td>
                                        </tr>
                                        <tr>
                                            <td><label><?php print lang('vt_vatprice'); ?>:</label></td>
                                            <td><input name="bill_vatprice" id="bill_vatprice" value="0" class="input-price itext ivalidate ui-widget-content ui-corner-all"></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2"><div id="error_bill_vatprice" class="error"></div></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                            
                            <td>
                                <table>
                                    <tr>
                                        <td><label><?php print lang('vt_note'); ?>:</label></td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <textarea name="bill_note" style="width: 370px;" cols="40" rows="3"></textarea>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><label><?php print lang('vt_total+vat'); ?>:</label> <input type="text" name="bill_totalvat" id="bill_totalvat" value="0" class="input-price itext ivalidate ui-widget-content ui-corner-all"></td>
                                    </tr>
                                    <tr>
                                        <td><div id="error_bill_totalvat" class="error"></div></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
                
                </div>
                <div class="menu-button">
                    <div class="message"></div>
                    <button style="float: left" type="button" onclick="even_edit();"><?php print lang('btn_edit'); ?></button>
                    <button style="float: left" type="button" onclick="even_delete();"><?php print lang('btn_delete'); ?></button>
                    <button type="button" onclick="import_product_save();"><?php print lang('btn_nhapkho'); ?></button>
                    <div class="clear"></div>
                </div>
                <div id="error_table_product" class="error"></div>
                <table cellpadding="0" cellspacing="0" border="0" class="display" id="datatable_bill" active_url="<?php print site_url('vt/datatable_dvt'); ?>">
                    <thead>
                        <tr>
                            <th width="10px"><?php print lang('vt_stt'); ?></th>
                            <th><?php print lang('vt_ma'); ?></th>
                            <th width="200px"><?php print lang('vt_ten'); ?></th>
                            <th><?php print lang('vt_dvt'); ?></th>
                            <th><?php print lang('vt_tenphanloai'); ?></th>
                            <th width="100px"><?php print lang('vt_slnhap'); ?></th>
                            <th><?php print lang('vt_dongia'); ?></th>
                            <th><?php print lang('vt_note'); ?></th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
                
            <?php print '</form>'; ?>
        </div>
    </div>
    <div class="clear"></div>
</div>

<div id="dialog_form_add" title="<?php print lang('vt_title_themvattu'); ?>" active_url="<?php print site_url('nk/ajax_loadfrm_import/'); ?>"></div>
<div id="dialog_form_edit" title="<?php print lang('vt_title_suavattu'); ?>" active_url="<?php print site_url('nk/ajax_loadfrm_import/'); ?>"></div>
<div id="dialog_confrim_delete" title="<?php print lang('title_thongbao'); ?>" active_url="">
    <p><?php print lang('msg_delete'); ?></p>
</div>